################################################################################
#(1) 固定模式. 定义路径信息
################################################################################
CC = gcc

#dir
TOPDIR_MP := ..
CURDIR_MP := .
MAKEPATH := $(abspath $(lastword $(MAKEFILE_LIST)))
CURDIR := $(shell dirname $(MAKEPATH))
#expander路径
TOPDIR := $(abspath $(CURDIR))

#代码路径
SRCS := $(wildcard $(TOPDIR)/*.c)
#SRCS += $(wildcard $(TOPDIR)/module01introduction/*.c)


INCS :=-I/usr/local/include/CUnit
INCS +=-I$(TOPDIR)/include

OBJS := *.o
UDLL := $(CURDIR_MP)/test
XML  := *.xml
TXT  := *.txt *.log ./common/debug/*.log
GCNO := *.gcno
GCNO += *.gcov
GCDA := *.gcda
GCDA += *.info
GCDA += results
GCDA += app.info
CORE := core*

###############################################

CUNIT := /usr/local/lib/libcunit.a

CFLAGS := -c  
CFLAGS += -Wno-unused-function
CFLAGS += -Wall
CFLAGS += -g -ggdb
CFLAGS += -Wno-unused-but-set-variable -Wno-maybe-uninitialized -Wno-pointer-arith 
CFLAGS += -Wno-write-strings -Wall -Werror -Wno-address -Wno-sign-compare

GCOV   := -fprofile-arcs -ftest-coverage
#GCOV   += -fsanitize=address -fno-omit-frame-pointer

DP_FLAGS := -E -MM
	
all: compile link

compile:
	$(CC) $(GCOV) $(CFLAGS) $(SRCS) $(INCS) 

link: 
	$(CC) $(GCOV) -o $(UDLL) $(OBJS) $(CUNIT)
clean:
	-rm -rf $(OBJS)
	-rm -rf $(UDLL)
	-rm -rf $(XML)
	-rm -rf $(TXT)
	-rm -rf $(GCNO)
	-rm -rf $(GCDA)
	-rm -rf *.bin 
	-rm -rf $(CORE)
rebuild: clean all
